import AbstractCanvas from './canvas'
import config from '@/config'
import TankModel from '@/model/tank'

class Tank extends AbstractCanvas<TankModel> {
    public override render(): void {
        // tank 允许重叠
        super.createModels(config.tank.num, TankModel, 'top', true)

        setInterval(() => this.renderModels(), config.tank.renderTime)
        // this.renderModels()
        // console.log('tank num', this.items.length)
    }

    protected override renderModels() {
        super.clearCanvas()
        this.models.forEach((d) => {
            d.move()
            d.draw()
        })
    }

    protected override setCanvasId(): void {
        this.canvas.id = 'canvas-tank'
    }
}

export default new Tank()
